<template>
    <div>
        <el-card class="!border-none mb-4" shadow="never">
            <el-form class="mb-[-16px]" :model="queryParams" inline label-width="90px">
                <el-form-item label="状态" prop="status">
                    <el-select class="w-[280px]" style="width: 280px" v-model="queryParams.status" clearable
                        placeholder="请选择部门状态">
                        <el-option label="全部" value=""></el-option>
                        <el-option v-for="(item, index) in dictData.show_status" :key="index" :label="item.name"
                            :value="item.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="卡号" prop="account">
                    <el-input class="w-[280px]" v-model="queryParams.account" clearable placeholder="请输入卡号" />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="resetPage">查询</el-button>
                    <el-button @click="resetParams">重置</el-button>
                </el-form-item>
            </el-form>
        </el-card>
        <el-card class="!border-none" v-loading="pager.loading" shadow="never">

            <div class="mt-4">
                <el-table :data="pager.lists" @selection-change="handleSelectionChange">
                    <el-table-column type="selection" width="55" />
                    <el-table-column label="卡号" prop="account" />
                    <el-table-column label="状态" prop="status">
                        <template #default="{ row }">

                            <el-tag v-if="row.status == 1" type="success">已激活</el-tag>

                            <el-tag v-if="row.status == 0" type="info">未激活</el-tag>
                        </template>
                    </el-table-column>
                    <el-table-column label="激活用户" prop="user.account" />

                    <el-table-column label="价格" prop="price" />
                    <el-table-column label="产品" prop="product_id" />

                </el-table>
            </div>
            <div class="flex mt-4 justify-end">
                <pagination v-model="pager" @change="getLists" />
            </div>
        </el-card>
        <import-popup ref="importRef" @success="getLists" />
    </div>
</template>

<script lang="ts" setup name="cardLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'

import { apiCardLists } from '@/api/merchantcenter'

// 查询条件
const queryParams = reactive({
    status: '',
    account: ''
})

// 选中数据
const selectData = ref<any[]>([])

// 表格选择后回调事件
const handleSelectionChange = (val: any[]) => {
    selectData.value = val.map(({ id }) => id)
}


// 获取字典数据
const { dictData } = useDictData('show_status')

// 分页相关
const { pager, getLists, resetParams, resetPage } = usePaging({
    fetchFun: apiCardLists,
    params: queryParams
})



getLists()
</script>
